package com.example.administrator.ygddriver.order;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.FragmentTransaction;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;

import com.example.administrator.ygddriver.R;
import com.example.administrator.ygddriver.base.BaseActivity;
import com.example.administrator.ygddriver.order.getorder.GetOrderFragment;
import com.example.administrator.ygddriver.order.outorder.OutOrderFragment;
import com.example.administrator.ygddriver.tool.SimpleToolbar;

/**
 * 服务订单
 */
public class OrderActivity extends BaseActivity implements View.OnClickListener {
    private SimpleToolbar simpleToolbar;
    private int[] rbnId = {R.id.activity_order_get_rb, R.id.activity_order_out_rb};
    private FragmentTransaction transaction;

    @Override
    public int initLayout() {
        return R.layout.activity_order;
    }

    @Override
    public void initView() {
        simpleToolbar = findViewById(R.id.activity_order_stb);
        for (int i = 0; i < rbnId.length; i++) {
            findViewById(rbnId[i]).setOnClickListener(this);

        }
    }

    @Override
    public void initDate() {
        setSimpleToolbar();
        getSupportFragmentManager().beginTransaction().replace(R.id.activity_order_fl, new GetOrderFragment()).commit();
    }

    @Override
    public void onClick(View v) {
        transaction = getSupportFragmentManager().beginTransaction();
        switch (v.getId()) {
            case R.id.activity_order_get_rb:
                transaction.replace(R.id.activity_order_fl, new GetOrderFragment());
                break;
            case R.id.activity_order_out_rb:
                transaction.replace(R.id.activity_order_fl, new OutOrderFragment());
                break;
        }
        transaction.commit();
    }

    private void setSimpleToolbar() {
        simpleToolbar.setMainTitle("服务订单");
        simpleToolbar.setMainTitleColor("#000000");
        simpleToolbar.setBackIv(R.mipmap.left_title);
        simpleToolbar.setToolColor("#ffffff");
        simpleToolbar.setBackIvClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }


}
